﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;

namespace Kaesoft.Hospedaje.Common
{
    public partial class CambiarClaveView : UserControl
    {
        public CambiarClaveView()
        {
            InitializeComponent();
            this.Loaded += CambiarClaveView_Loaded;
        }

        void CambiarClaveView_Loaded(object sender, RoutedEventArgs e)
        {
            var contexto = (CambiarClaveViewModel)DataContext;
            contexto.VentanaClaveModelo.PasswordChanged += VentanaClaveModelo_PasswordChanged;
            contexto.VentanaClaveModelo.WindowClosing += VentanaClaveModelo_WindowClosing;
        }

        void VentanaClaveModelo_WindowClosing(object sender, EventArgs e)
        {
            CierraElementoTab();
        }

        void VentanaClaveModelo_PasswordChanged(object sender, EventArgs e)
        {
            CierraElementoTab();
        }

        private void CierraElementoTab() 
        {
            var objetoPadre = (RadTabItem)this.Parent;
            var marcoDeTrabajo = (RadTabControl)objetoPadre.Parent;
            marcoDeTrabajo.Items.Remove(objetoPadre);
        }
    }
}
